<%--
  Created by IntelliJ IDEA.
  User: 曾幼九
  Date: 2023/3/4
  Time: 15:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>JSP基本语法</title>
</head>
<body>

<%--JSP表达式
    作用：用来将程序的输出，输出到客户端
    格式： <%= 变量或者表达式%>
--%>

<%= new java.util.Date()%>

<hr>


<%--JSP脚本片段--%>
<%
  int sum = 0;
  for (int i = 1; i <= 100; i++) {
    sum += i;
  }
  out.println("<h1>Sum=" + sum + "</h1>");
%>

<hr>


<%
  int x = 10;
  out.println(x);
%>
<p>这是一个JSP文档</p>
<%
  int y = 2;
  out.println(y);
%>

<hr>

<%--在代码中嵌入HTML元素--%>
<%
  for(int i = 0; i < 5; i++ ){
%>
<h1>Hello,world  <%=i%></h1>
<%
  }
%>

<hr>

<%!
  static {
    System.out.println("Loading Servlet ... ");
  }
  private int  global_var = 0;
  public void test(){
    System.out.println("进入了方法test... ");
  }
%>

<hr>

<%-- JSP注释 --%>
<!-- HTML注释 -->


<hr>


</body>
</html>
